﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/Admin/_AdminLayout.cshtml";
}
<script src="~/Content/CSS/admin/datetimepicker/jquery-1.9.1.js"></script>
<link href="~/Content/CSS/admin/datetimepicker/jquery-ui-1.10.3.custom.css" rel="stylesheet" />
<script src="~/Content/CSS/admin/datetimepicker/jquery-ui-1.10.3.custom.js"></script>
@model List<BabyToys.Models.ViewModel.TonKhoViewModel>
@using PagedList.Mvc;
@using PagedList;
<script>
    $(function () {
        $("#from").datepicker({
            defaultDate: "+1w",
            changeMonth: true,
            numberOfMonths: 1,
            dateFormat: 'dd/mm/yy',
            onClose: function (selectedDate) {
                $("#to").datepicker("option", "minDate", selectedDate);
            }
        });
        $("#to").datepicker({
            defaultDate: "+1w",
            changeMonth: true,
            dateFormat: 'dd/mm/yy',
            numberOfMonths: 1,
            onClose: function (selectedDate) {
                $("#from").datepicker("option", "maxDate", selectedDate);
            }
        });
        //$("#indate").datepicker({
        //    defaultDate: "+1w",
        //    changeMonth: true,
        //    dateFormat: 'dd/mm/yy',
        //    numberOfMonths: 1,
        //    onClose: function (selectedDate) {
        //        $("#indate").datepicker("option", "maxDate", selectedDate);
        //    }
        //});
    });
</script>
<div id="content" class="span10">
    <!-- content starts -->
    <div>
        <ul class="breadcrumb">
            <li>
                <a href="#">Home</a> <span class="divider">/</span>
            </li>
            <li>
                <a href="#">Danh sách đơn hàng</a>
            </li>
        </ul>
    </div>
    <div class="row-fluid sortable">
        <div class="box span12">
            <div class="box-content">
                <div class="row-fluid">
                    <div class="span12 form-inline">
                        @using (Html.BeginForm("TonKho", "AdminSanPham", FormMethod.Get))
                        {
                            <div id="search-box" style="text-align: left">
                                @*<input type="radio" name="ynRadio" class="radioBtn" value="range" checked="checked" />*@
                                <label for="from">từ ngày</label>
                                <input type="text" id="from" name="from" value="@ViewBag.FromDate"/>
                                <label for="to">đến ngày</label>
                                <input type="text" id="to" name="to" value="@ViewBag.ToDate"/>
                                @*<input type="radio" name="ynRadio" class="radioBtn" value="theongay" />
                                <label for="from">Theo ngày</label>
                                <input type="text" id="date" name="date" value="@ViewBag.InDate" />*@
                                <input type="submit" value="Lọc" class="button4" />
                                <input type="submit" value="Nhập lại" class="button4" onclick="Reset()" />
                               @* <script>
                                    function Reset() {
                                        $("#indate").val("");
                                        $("#from").val("");
                                        $("#to").val("");
                                    }
                                    $(".radioBtn").click(function () {
                                        $("#in").attr("disabled", true);
                                        if ($("input[name=ynRadio]:checked").val() == "theongay") {
                                            $("#indate").attr("disabled", false);
                                            $("#from").attr("disabled", true);
                                            $("#to").attr("disabled", true);
                                        }
                                        if ($("input[name=ynRadio]:checked").val() == "range") {
                                            $("#indate").attr("disabled", true);
                                            $("#from").attr("disabled", false);
                                            $("#to").attr("disabled", false);
                                        }
                                    });
                                </script>*@
                            </div>
                        }
                    </div>

                </div>
                <div class="row-fluid">
                    <div style="float:right;margin-right:20px;">
                        Hiển thị 
               <select id="HienThi" style="width: 100px;">
                   <option value="5" @if (ViewBag.HienThi == 10)
                                     { @:selected="selected" 
                       }>5</option>
                   <option value="10" @if (ViewBag.HienThi == 10)
                                      { @:selected="selected" 
                       }>10</option>
                   <option value="15" @if (ViewBag.HienThi == 15)
                                      { @:selected="selected" 
                       }>15</option>
                   <option value="20" @if (ViewBag.HienThi == 20)
                                      { @:selected="selected" 
                       }>20</option>
                   <option value="50" @if (ViewBag.HienThi == 50)
                                      { @:selected="selected" 
                       }>50</option>
               </select>
                        <script>
                            $("#HienThi").change(function () {
                                var hienthi = $(this).val();
                                window.location.href = 'http://' + window.location.host + '/Adminsanpham/tonkho/?hienthi=' + hienthi + '&from=@ViewBag.FromDate&to=@ViewBag.ToDate';

                            });
                        </script>
                    </div>
                </div>

            </div>
            <div class="clearfix"></div>
            <table class="table table-striped table-bordered bootstrap-datatable datatable">
                <thead>
                    <tr>
                        <th>Id sản phẩm</th>
                        <th>Tên sản phẩm</th>
                        <th>Tồn đầu</th>
                        <th>Nhập</th>
                        <th>Xuất</th>
                        <th>Tồn cuối</th>
                    </tr>
                </thead>
                <tbody>
                    @{PagedList<BabyToys.Models.ViewModel.TonKhoViewModel> tonkhos = ViewBag.tonkhos;}
                    @foreach (var tonkho in tonkhos)
                    {
                        <tr class="item_row" style="border-color: #F0F0F0; border-style: Solid; height: 40px;">
                            <td class="item_float">@tonkho.SanPham.IdSanPham</td>
                            <td class="item_float"><a href="~/Adminsanpham/Sua/@tonkho.SanPham.TenSP">@tonkho.SanPham.TenSP</a></td>
                            <td class="item_float">@tonkho.TonDau</td>
                            <td class="item_float">@tonkho.Nhap</td>
                            <td class="item_float">@tonkho.Xuat</td>
                            <td class="item_float">@tonkho.TonCuoi</td>
                            <td><a href="~/adminsanpham/chitiettonkho/@tonkho.SanPham.IdSanPham">Chi tiết</a></td>
                        </tr>
                    }
                </tbody>
            </table>
            <div class="pagination pagination-centered">
                @Html.PagedListPager((IPagedList)ViewBag.tonkhos, page => Url.Action("TonKho", new { page, hienthi = ViewBag.HienThi, from = ViewBag.FromDate, to = ViewBag.ToDate, indate = ViewBag.Indate }), PagedListRenderOptions.OnlyShowFivePagesAtATime)
            </div>
        </div>
    </div>
</div>


